import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_chat/page/login_page.dart';

class MinePage extends StatefulWidget {
  @override
  _MinePageState createState() => _MinePageState();
}

class _MinePageState extends State<MinePage> {
  @override
  // ignore: must_call_super
  void initState() {}

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
//          padding: EdgeInsets.symmetric(
//            horizontal: MediaQuery.of(context).size.width * 0.1,
//          ),
          padding: EdgeInsets.all(16.0),
          child: Column(children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                RaisedButton(
                  child: Text("normal"),
                  onPressed: () {
                    print('normal');
                  },
                ),
                Text("normal")
              ],
            ),
            ButtonTheme(
              minWidth: 2000.0,
              padding: const EdgeInsets.all(5.0),
              child: RaisedButton(
                onPressed: () {
                  signOut();
                },
                color: Colors.red,
//                    textColor: Colors.black87,
                textColor: Colors.white,
                // 设置圆角
                shape: RoundedRectangleBorder(
                  // 设置圆角颜色
                  side: BorderSide(
                    color: Colors.redAccent,
                  ),
                  // 设置圆角角度
                  borderRadius: BorderRadius.all(Radius.circular(5)),
                ),
                child: Text("登  出"),
              ),
            ),
          ])),
    );
  }

  void signOut() async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    prefs.remove('login');
    Navigator.pushAndRemoveUntil(context,
        new MaterialPageRoute(builder: (context) {
      return LoginPage();
    }), (route) => route.settings.name == "/");
    print('登出');
  }
}
